package com.bwie.controller;

import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author 军哥
 * @version 1.0
 * @description: 用户接口层
 * @date 2024/11/2 11:55
 */

@RestController
@RequestMapping(value = "/user/user")
public class TbUserController {

    @Autowired
    TbUserService tbUserService;

    /**
     * 用户登录
     * @param loginInfoVo
     * @return
     */
    @PostMapping(value = "/login")
    public R login(@Validated @RequestBody LoginInfoVo loginInfoVo) {
        return tbUserService.login(loginInfoVo);
    }

    /**
     * 根据ID查询用户信息，用于OpenFeign
     * @param userId
     * @return
     */
    @PostMapping(value = "/getUserById/{userId}")
    public R getUserById(@PathVariable("userId") Integer userId) {
        return tbUserService.getUserById(userId);
    }
}
